//
//  NewsPicCell.m
//  口袋
//
//  Created by why on 15/5/25.
//  Copyright (c) 2015年 口袋. All rights reserved.
//

#import "NewsPicCell.h"
#import "DKNightVersion.h"

#define WIDTH [UIScreen mainScreen].bounds.size.width
#define HEIGHT [UIScreen mainScreen].bounds.size.height / 5.5
#define UIColorFromRGB(rgbValue) [UIColor colorWithRed:((float)((rgbValue & 0xFF0000) >> 16))/255.0 green:((float)((rgbValue & 0xFF00) >> 8))/255.0 blue:((float)(rgbValue & 0xFF))/255.0 alpha:1.0]


@implementation NewsPicCell

- (void)dealloc
{
    [_label release];
    [_imageView1 release];
    [_imageView2 release];
    [_imageView3 release];
    [_comments release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self createCell];
        [DKNightVersionManager addClassToSet:self.class];
        self.nightBackgroundColor = UIColorFromRGB(0x343434);
    }
    return self;
}

- (void)createCell
{
    _imageView1 = [[UIImageView alloc] initWithFrame:CGRectMake(10, HEIGHT / 4, (WIDTH - 40) / 3, HEIGHT / 4 * 3 - 10)];
    [self.contentView addSubview:_imageView1];
    [_imageView1 release];
    
    _imageView2 = [[UIImageView alloc] initWithFrame:CGRectMake((WIDTH - 40) / 3 + 20, HEIGHT / 4, (WIDTH - 40) / 3, HEIGHT / 4 * 3 - 10)];
    [self.contentView addSubview:_imageView2];
    [_imageView2 release];
    
    _imageView3 = [[UIImageView alloc] initWithFrame:CGRectMake((WIDTH - 40) / 3 * 2 + 30, HEIGHT / 4, (WIDTH - 40) / 3, HEIGHT / 4 * 3 - 10)];
    [self.contentView addSubview:_imageView3];
    [_imageView3 release];
    
    _label = [[UILabel alloc] initWithFrame:CGRectMake(10, 0, WIDTH, HEIGHT / 4)];
    [self.contentView addSubview:_label];
    _label.font = [UIFont boldSystemFontOfSize:17];
    _label.nightTextColor = [UIColor lightGrayColor];
    [_label release];
    
    _comments = [[UILabel alloc] initWithFrame:CGRectMake(WIDTH / 10 * 7, 0, WIDTH / 10 * 3 - 10, HEIGHT / 4)];
    [self.contentView addSubview:_comments];
    _comments.font = [UIFont systemFontOfSize:14 weight:0.05];
    _comments.textColor = [UIColor grayColor];
    _comments.textAlignment = 2;
    [_comments release];
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
